package com.woniuxy.userdemo.service;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.woniuxy.userdemo.entity.User;
import com.woniuxy.userdemo.mapper.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserServiceImpl  implements IUserService{
    @Autowired
    UserMapper userMapper ;

    @Override
    public User login(String username) {
        return userMapper.selectUserByName(username);
    }

    @Override
    public PageInfo<User> findUserByPage(String username, Integer education, Integer now, Integer size) {
        PageHelper.startPage(now,size);
        List<User> users = userMapper.selectUserByCons(username,education);
        return new PageInfo<>(users);
    }

    @Override
    public User findUserById(int id) {
        return userMapper.selectUserById(id);
    }

    @Override
    public void modify(User user) {
        userMapper.update(user);
    }

    @Override
    public void removeByKey(int id) {
        userMapper.deleteByKey(id);
    }

    @Override
    public void add(User user) {
        userMapper.insert(user);
    }

    @Override
    public void test() {
        System.out.println("dsdsdasfsfg");
    }

    @Override
    public void test01() {
        System.out.println("AAAAAAAAAAAAAAAAAA");
    }

    @Override
    public void testWorkSpace() {
        System.out.println("WWWWWWWWWWWWWWWWWW");
    }
}
